package com.chen.lock;

// Synchronized版可重入锁
public class ReentrantLockTest1 {
    public static void main(String[] args) {

        Phone phone = new Phone();

        new Thread(phone::sms, "A").start();
        new Thread(phone::sms, "B").start();

    }
}

class Phone {

    // 一个锁里面有另一个锁
    public synchronized void sms() {
        System.out.println(Thread.currentThread().getName() + "发短信");
        call();
    }

    private synchronized void call() {
        System.out.println(Thread.currentThread().getName() + "打电话");
    }

}